<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/6/2 0002
 * Time: 下午 3:51
 */

namespace Common\Model;

use ExtendApi;
class SyncApiModel
{
    protected $url = 'http://dc.shenghuigo.com/api.php';
    protected $appId;
    protected $sign;
    public $table;
    function __construct($table)
    {
        $this->appId = '';
        $this->table = $table;
    }

    public function Sync(){
        $from_table = M('tmp_data');
        $to_table     = M('data');
        $goods = $from_table->find();
        $arr  = [];
        foreach ($goods as $k => $v){
            $api = new ExtendApi();
            if(!$to_table->where('code='.$v['code'])){
                $res = $api->goodsAdd($goods[$k]);
                if ($res->msg == 'success' && $res->code == 200)
                {
                    unset($api);
                    return $res;
                }
                else
                {
                    return false;
                }
            }
        }
    }
    public function sendData($data){

    }
}